<script setup>
import { userIsLogin } from '@/api/user'
import LetterNav from './components/LetterNav.vue'
import WriteLetterBox from './components/WriteLetterBox.vue'
import { disableBlackTheme } from './utils/tool'
import { ref } from 'vue'
import { useRouter } from 'vue-router'

disableBlackTheme()
// 该功能需要登录使用
const centerDialogVisible = ref(false)
const islogin = async () => {
  const res = await userIsLogin()
  if (res.data.data == false) {
    // 用户未登录
    centerDialogVisible.value = true
  }
}
islogin()

// 跳转
const router = useRouter()
const to = () => {
  router.push('/login?name=letter/write')
}
</script>

<!-- 写信页面 -->
<template>
  <el-dialog
    v-model="centerDialogVisible"
    title="注意！"
    width="500"
    align-center
    :close-on-press-escape="false"
    :close-on-click-modal="false"
  >
    <div style="display: flex; align-items: center">
      <span>为了您的使用体验，写信功能需要登录后使用。</span>
    </div>

    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="to()"> 确定 </el-button>
      </div>
    </template>
  </el-dialog>
  <el-scrollbar height="100vh">
    <letter-nav></letter-nav>
    <!-- <letter-nav-shadow></letter-nav-shadow> -->
    <write-letter-box></write-letter-box>
  </el-scrollbar>
</template>

<style scoped></style>
